//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2021 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto/tree/main/CodeGenerator. DO NOT EDIT.

import SotoCore

/// Error enum for CodeStarNotifications
public struct CodeStarNotificationsErrorType: AWSErrorType {
    enum Code: String {
        case accessDeniedException = "AccessDeniedException"
        case concurrentModificationException = "ConcurrentModificationException"
        case configurationException = "ConfigurationException"
        case invalidNextTokenException = "InvalidNextTokenException"
        case limitExceededException = "LimitExceededException"
        case resourceAlreadyExistsException = "ResourceAlreadyExistsException"
        case resourceNotFoundException = "ResourceNotFoundException"
        case validationException = "ValidationException"
    }

    private let error: Code
    public let context: AWSErrorContext?

    /// initialize CodeStarNotifications
    public init?(errorCode: String, context: AWSErrorContext) {
        guard let error = Code(rawValue: errorCode) else { return nil }
        self.error = error
        self.context = context
    }

    internal init(_ error: Code) {
        self.error = error
        self.context = nil
    }

    /// return error code string
    public var errorCode: String { self.error.rawValue }

    /// AWS CodeStar Notifications can't create the notification rule because you do not have sufficient permissions.
    public static var accessDeniedException: Self { .init(.accessDeniedException) }
    /// AWS CodeStar Notifications can't complete the request because the resource is being modified by another process. Wait a few minutes and try again.
    public static var concurrentModificationException: Self { .init(.concurrentModificationException) }
    /// Some or all of the configuration is incomplete, missing, or not valid.
    public static var configurationException: Self { .init(.configurationException) }
    /// The value for the enumeration token used in the request to return the next batch of the results is not valid.
    public static var invalidNextTokenException: Self { .init(.invalidNextTokenException) }
    /// One of the AWS CodeStar Notifications limits has been exceeded. Limits apply to accounts, notification rules, notifications, resources, and targets. For more information, see Limits.
    public static var limitExceededException: Self { .init(.limitExceededException) }
    /// A resource with the same name or ID already exists. Notification rule names must be unique in your AWS account.
    public static var resourceAlreadyExistsException: Self { .init(.resourceAlreadyExistsException) }
    /// AWS CodeStar Notifications can't find a resource that matches the provided ARN.
    public static var resourceNotFoundException: Self { .init(.resourceNotFoundException) }
    /// One or more parameter values are not valid.
    public static var validationException: Self { .init(.validationException) }
}

extension CodeStarNotificationsErrorType: Equatable {
    public static func == (lhs: CodeStarNotificationsErrorType, rhs: CodeStarNotificationsErrorType) -> Bool {
        lhs.error == rhs.error
    }
}

extension CodeStarNotificationsErrorType: CustomStringConvertible {
    public var description: String {
        return "\(self.error.rawValue): \(self.message ?? "")"
    }
}
